package com.qfedu.gytv.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.qfedu.gytv.vo.R;
import com.qfedu.gytv.entity.User;
import com.qfedu.gytv.dao.UserDao;
import com.qfedu.gytv.service.intf.UserService;

/**
 * @description: 码起 自动生成代码
 * @author: my
 * @create: 2020-09-16 20:01:16
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public R addUser(User user) {
        if (userDao.insert(user) > 0) {
            return R.ok();
        } else {
            return R.fail("新增失败");
        }
    }

    @Override
    public R delById(int id){
        if(userDao.deleteById(id)>0){
        return R.ok();
        }else{
        return R.fail("删除失败");
        }
    }

    @Override
    public R all(){
        return R.ok(userDao.all());
    }

    @Override
    public R selectByPhone(String phone) {
        return R.ok(userDao.selectByPhone(phone));
    }
}
